<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Multi term vectors API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'docs-multi-termvectors.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/docs-multi-termvectors.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/docs-multi-termvectors.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/docs-multi-termvectors.html" rel="nofollow" target="_blank">../en/docs-multi-termvectors.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="docs.html">Document APIs</a></span>
»
<span class="breadcrumb-node">Multi term vectors API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="docs-termvectors.html">« Term vectors API</a>
</span>
<span class="next">
<a href="docs-refresh.html"><code class="literal">?refresh</code> »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="docs-multi-termvectors"></a>Multi term vectors API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/docs/multi-termvectors.asciidoc">edit</a>
</h2>
</div></div></div>

<p>Retrieves multiple term vectors with a single request.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST /_mtermvectors
{
   "docs": [
      {
         "_index": "twitter",
         "_id": "2",
         "term_statistics": true
      },
      {
         "_index": "twitter",
         "_id": "1",
         "fields": [
            "message"
         ]
      }
   ]
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1568.console"></div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="docs-multi-termvectors-api-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/docs/multi-termvectors.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">POST /_mtermvectors</code></p>
<p><code class="literal">POST /&lt;index&gt;/_mtermvectors</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="docs-multi-termvectors-api-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/docs/multi-termvectors.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You can specify existing documents by index and ID or
provide artificial documents in the body of the request.
The index can be specified the body of the request or in the request URI.</p>
<p>The response contains a <code class="literal">docs</code> array with all the fetched termvectors.
Each element has the structure provided by the <a class="xref" href="docs-termvectors.html" title="Term vectors API">termvectors</a>
API.</p>
<p>See the <a class="xref" href="docs-termvectors.html" title="Term vectors API">termvectors</a> API for more information about the information
that can be included in the response.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="docs-multi-termvectors-api-path-params"></a>Path parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/docs/multi-termvectors.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">&lt;index&gt;</code>
</span>
</dt>
<dd>
(Optional, string) Name of the index that contains the documents.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="docs-multi-termvectors-api-query-params"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/docs/multi-termvectors.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">fields</code>
</span>
</dt>
<dd>
<p>(Optional, string)
Comma-separated list or wildcard expressions of fields
to include in the statistics.</p>
<p>Used as the default list
unless a specific field list is provided
in the <code class="literal">completion_fields</code> or <code class="literal">fielddata_fields</code> parameters.</p>
</dd>
<dt>
<span class="term">
<code class="literal">field_statistics</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the response includes the document count, sum of document frequencies,
and sum of total term frequencies.
Defaults to <code class="literal">true</code>.
</dd>
<dt>
<span class="term">
<code class="literal">&lt;offsets&gt;</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the response includes term offsets.
Defaults to <code class="literal">true</code>.
</dd>
<dt>
<span class="term">
<code class="literal">payloads</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the response includes term payloads.
Defaults to <code class="literal">true</code>.
</dd>
<dt>
<span class="term">
<code class="literal">positions</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the response includes term positions.
Defaults to <code class="literal">true</code>.
</dd>
<dt>
<span class="term">
<code class="literal">preference</code>
</span>
</dt>
<dd>
(Optional, string) Specifies the node or shard the operation should be
performed on. Random by default.
</dd>
<dt>
<span class="term">
<code class="literal">routing</code>
</span>
</dt>
<dd>
(Optional, string) Target the specified primary shard.
</dd>
<dt>
<span class="term">
<code class="literal">realtime</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the request is real-time as opposed to near-real-time.
Defaults to <code class="literal">true</code>. See <a class="xref" href="docs-get.html#realtime" title="Realtime">Realtime</a>.
</dd>
<dt>
<span class="term">
<code class="literal">term_statistics</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, the response includes term frequency and document frequency.
Defaults to <code class="literal">false</code>.
</dd>
<dt>
<span class="term">
<code class="literal">version</code>
</span>
</dt>
<dd>
(Optional, boolean) If <code class="literal">true</code>, returns the document version as part of a hit.
</dd>
<dt>
<span class="term">
<code class="literal">version_type</code>
</span>
</dt>
<dd>
(Optional, enum) Specific version type: <code class="literal">internal</code>, <code class="literal">external</code>,
<code class="literal">external_gte</code>.
</dd>
</dl>
</div>
<h4>
<a id="docs-multi-termvectors-api-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/docs/multi-termvectors.asciidoc">edit</a>
</h4>
<p>If you specify an index in the request URI, the index does not need to be specified for each documents
in the request body:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST /twitter/_mtermvectors
{
   "docs": [
      {
         "_id": "2",
         "fields": [
            "message"
         ],
         "term_statistics": true
      },
      {
         "_id": "1"
      }
   ]
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1569.console"></div>
<p>If all requested documents are in same index and the parameters are the same, you can use the
following simplified syntax:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST /twitter/_mtermvectors
{
    "ids" : ["1", "2"],
    "parameters": {
    	"fields": [
         	"message"
      	],
      	"term_statistics": true
    }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1570.console"></div>
<div class="section">
<div class="titlepage"><div><div>
<h4 class="title">
<a id="docs-multi-termvectors-artificial-doc"></a>Artificial documents<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/docs/multi-termvectors.asciidoc">edit</a>
</h4>
</div></div></div>
<p>You can also use <code class="literal">mtermvectors</code> to generate term vectors for <em>artificial</em> documents provided
in the body of the request. The mapping used is determined by the specified <code class="literal">_index</code>.</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">POST /_mtermvectors
{
   "docs": [
      {
         "_index": "twitter",
         "doc" : {
            "user" : "John Doe",
            "message" : "twitter test test test"
         }
      },
      {
         "_index": "twitter",
         "doc" : {
           "user" : "Jane Doe",
           "message" : "Another twitter test ..."
         }
      }
   ]
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1571.console"></div>
</div>

</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="docs-termvectors.html">« Term vectors API</a>
</span>
<span class="next">
<a href="docs-refresh.html"><code class="literal">?refresh</code> »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>